package org.future.wsdl.data;
/**
 * 嵌套在 xs:sequence 内的 xs:element
 * @author dycc
 *
 */
public class XElementInner {

    private String name;
    
    private String minOccurs;
    
    private String maxOccurs;
    
    private String nillable;
    
    private String type;
    
    private XComplexType complexType;
    
    private WsdlOperation wsdlOperation;
    
    // name
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    // minOccurs
    public String getMinOccurs() {
        return minOccurs != null ? minOccurs : "0";
    }
    public void setMinOccurs(String minOccurs) {
        this.minOccurs = minOccurs;
    }
    // maxOccurs
    public String getMaxOccurs() {
        return maxOccurs;
    }
    public void setMaxOccurs(String maxOccurs) {
        this.maxOccurs = maxOccurs;
    }
    // nillable
    public String getNillable() {
        return nillable;
    }
    public void setNillable(String nillable) {
        this.nillable = nillable;
    }
    // type
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    // isComplexType
    public boolean isComplexType(){
        String dataType = type;
        int index = dataType.indexOf(":");
        if(index > -1){
            dataType = dataType.substring(index + 1);
        }
        return !BaseTypeTable.isSimpleXmlType(dataType);
    }
    // complexType
    public XComplexType getComplexType() {
        return complexType;
    }
    public void setComplexType(XComplexType complexType) {
        this.complexType = complexType;
    }
    // wsdlOperation
    public WsdlOperation getWsdlOperation() {
        return wsdlOperation;
    }
    public void setWsdlOperation(WsdlOperation wsdlOperation) {
        this.wsdlOperation = wsdlOperation;
    }
    
    /**
     * toString
     */
    public String toString(){
        StringBuffer sb = new StringBuffer();
        sb.append("<xs:element");
        sb.append(" name=\"" + name + "\"");
        if(minOccurs != null){
            sb.append(" minOccurs=\"" + minOccurs + "\"");
        }
        if(maxOccurs != null){
            sb.append(" maxOccurs=\"" + maxOccurs + "\"");
        }
        if(nillable != null){
            sb.append(" nillable=\"" + nillable + "\"");
        }
        sb.append(" type=\"" + type + "\"");
        sb.append(" />");
        return sb.toString();
    }
}
